package cn.gson.boot.model.dao;

import cn.gson.boot.model.pojos.RoleGong;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;

import javax.transaction.Transactional;

public interface RoleGongDao extends CrudRepository<RoleGong,Integer> {

    // 先删除此角色的所有的功能
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from role_gong where jue_id=?1")
    public void deletejuesegong(Integer jueId);


    // 根据角色id和功能id来删除
    @Transactional
    @Modifying(clearAutomatically = true)
    @Query(nativeQuery = true,value = "delete from role_gong where jue_id=?1 and gong_id2=?2")
    public void deleteByjueIdAndGongId(Integer jueId,Integer gongId);
}
